<template>
  <div id="app">
    <todo-list :item="todoListItem" @addItem="handleAddItem"></todo-list>
  </div>
</template>

<script>
import TodoList from "@/components/TodoList.vue";
import bus from "@/bus"
export default {
  name: "app",
  components: {
    TodoList
  },
  data() {
    return {
      todoListItem: [
      ]
    };
  },
  methods:{
    handleAddItem(content){
      this.todoListItem.push({
        content,
        timestamp:+new Date
      })
    }
  },
  mounted(){
    bus.$on('delete',(index)=>{
      this.todoListItem.splice(index,1);
    })
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
  min-width: 300px;
}
</style>
